//机构api
function getChildAgencys() {
    return new Promise((resolve, reject) => {
        axios({
            method: 'get',
            url: '/amc/sys/base/agency/search/child/list/'+layui.data('user').info.agencyCode,
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token}
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}

function saveAgency(params) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'post',
            url: '/amc/sys/base/agency/save',
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token},
            data: params
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}

function deletes(agencyCodes) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'delete',
            url: '/amc/sys/base/agency/deletes',
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token},
            data: agencyCodes
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}

function cancel(agencyCodes) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'put',
            url: '/amc/sys/base/agency/cancels',
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token},
            data: agencyCodes
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}

function update(agencyinfo) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'put',
            url: '/amc/sys/base/agency/update',
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token},
            data: agencyinfo
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}